extends "../calxJS_Hide/calxJS_Hide.gd"
func _init():
	pass
func _extInit():
	._extInit()
	chaName = "丸少爷"                   # 角色的名称
	attCoe.atkRan = 3                 # 攻击距离
	attCoe.maxHp = 5                 # 最大生命（每点代表112.5基础数值，取整数，下同）
	attCoe.atk = 6                   # 攻击力（每点代表8.5）
	attCoe.mgiAtk = 4                 # 魔法攻击（每点代表13.7）
	attCoe.def = 3                    # 物理防御（每点代表15）
	attCoe.mgiDef = 3               # 魔法防御（每点代表16.6）
	atkEff = "atk_dao" 
	xb = "神秘"
	lv = 3
	addSkillTxt("[人海战术]战斗开始时，自身四维提升己方上场生物lv之和*4，己方每阵亡一个非召唤单位，四维下降20点")
	addSkillTxt("[魔力丸丸]攻击时有30%概率使用魔力进行附加攻击，造成70%魔攻的神秘系真实伤害\n另外每10秒会进入<魔力丸丸>状态，持续5秒(不享受CD减免)")
	addSkillTxt("[通灵魔法扇]战斗开始时召唤1个受自身四维加成的小小丸加入战斗，小小丸在场时，自身受到的技能伤害由小小丸承受\n如果处于魔力丸丸状态，则受到的所有非特效伤害由小小丸承受")
	addCdSkill("tlmfs",12)


func _onHurt(atkInfo:AtkInfo):
	._onHurt(atkInfo)
	var chas = getAllChas(2)
	var b = hasBuff("molww")
	if b != null:
		for i in chas:
			if i.id == "cex___xxw" && i.team == team:
				if atkInfo.atkType != Chara.AtkType.EFF:
					if not i.isDeath:
						atkInfo.atkCha.hurtChara(i, atkInfo.atkVal, atkInfo.hurtType, Chara.AtkType.EFF)
						atkInfo.hurtVal = 0
	else:
		for i in chas:
			if i.id == "cex___xxw" && i.team == team:
				if atkInfo.atkType == Chara.AtkType.SKILL:
					if not i.isDeath:
						atkInfo.atkCha.hurtChara(i, atkInfo.atkVal, atkInfo.hurtType, Chara.AtkType.EFF)
						atkInfo.hurtVal = 0


func tlmfs():
	var summ = summChara("cex___xxw")
	if summ != null && not summ.isDeath:
		var ap = float(att.mgiAtk + att.atk + att.mgiDef + att.def)
		summ.attAdd.def = ap/4 as float
		summ.attAdd.mgiDef = ap/4 as float
		summ.attAdd.atk = ap/5 as float
		summ.attAdd.mgiAtk = ap/10 as float
		summ.attAdd.spd = ap/1000 as float


func _onAtkChara(atkInfo):
	._onAtkChara(atkInfo)
	if atkInfo.atkType == AtkType.NORMAL && sys.rndPer(30):
		typeHurtCha(atkInfo.hitCha,att.mgiAtk*0.7,Chara.HurtType.REAL,Chara.AtkType.EFF)

func _onBattleStart():
	._onBattleStart()
	var chas = getAllChas(2)
	for i in chas:
		addBuff(zhanshu.new(i.lv*4))
	tlmfs()

func _onCharaDel(cha):
	._onCharaDel(cha)
	var b = hasBuff("renhai")
	if cha==self:return
	if cha.isSumm:return
	if cha.isDeath==false:return
	if cha.team==self.team:
		if b == null:
			addBuff(renhai.new())
		else:
			b.att.atk -= 20
			b.att.mgiAtk -= 20
			b.att.def -= 20
			b.att.mgiDef -= 20

class zhanshu:
	extends Buff
	func _init(lv=null):
		attInit()
		isNegetive=false
		var dispelable = true
		id = "zhanshu"	
		att.atk += lv
		att.mgiAtk += lv
		att.def += lv
		att.mgiDef += lv

class renhai:
	extends Buff
	func _init():
		attInit()
		isNegetive=false
		var dispelable = true
		id = "renhai"	
		att.atk -= 20
		att.mgiAtk -= 20
		att.def -= 20
		att.mgiDef -= 20


var mlww = 0
func _onBattleEnd():
	._onBattleEnd()
	mlww = 0

func _upS():
	._upS()
	mlww += 1
	if mlww >= 10:
		var eff = sys.newEff("numHit", position, false, 1)
		eff.setText("魔力丸丸", "#FF0099")
		eff.anim.set_speed_scale(0.2)
		addBuff(molww.new(5))
		mlww = 0


class molww:
	extends Buff
	func _init(lv = 1):
		attInit()
		life = lv
		isNegetive=false
		var dispelable = true
		id = "molww"	

